package com.zhang.test_zhang.controller;

import com.zhang.test_zhang.entity.Order;
import com.zhang.test_zhang.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/order")
@Slf4j
public class OrderController {

    @Autowired
    private OrderService orderService;

    //支付100元
    @PostMapping("/pay")
    public String pay(Order order){
        log.info("支付100元:{}",order);
        return orderService.pay(order);
    }

    //用户定单id退款
    @PostMapping("/drawback")
    public String drawback(Order order){
        log.info("用户定单id退款:{}",order);
        return orderService.drawback(order);
    }

    //查询用户消费明细
    @GetMapping("/getAll")
    public List<Order> getAll(int userId){
        log.info("查询用户消费明细:{}",userId);
        return orderService.getAll(userId);
    }
}
